package com.right.health.app.utils;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.View;
import android.view.inputmethod.InputMethodManager;

/**
 * 键盘控制类
 * @author JimmyZhang
 * @date 2015-6-11上午11:23:24
 */

public class SoftInputUtil {
	/**
	 * 
	 * 此方法描述的是：隐藏软件盘
	 * 
	 * @author:JimmyZhang
	 * @since: 2013-11-23 下午1:55:19
	 * @param context
	 * @param windowToken
	 * @return void
	 */
	@SuppressLint("NewApi")
	public static void hideSoftInputMode(Context context, View windowToken) {
		if(windowToken != null && context != null) {
			InputMethodManager imm = ((InputMethodManager) context
					.getSystemService(Context.INPUT_METHOD_SERVICE));
			imm.hideSoftInputFromWindow(windowToken.getWindowToken(), 0);
		}
	}
	
	/**
	 * 
	 * 此方法描述的是：显示软键盘   
	 * @author:JimmyZhang  
	 * @since: 2013-11-23 下午1:55:56
	 * @param context
	 * @param windowToken
	 * @return void
	 */
	@SuppressLint("NewApi")
	public static void showSoftInputMode(Context context, View windowToken) {
		if(context != null && windowToken != null) {
			final InputMethodManager imm = (InputMethodManager) context
					.getSystemService(Context.INPUT_METHOD_SERVICE);
			imm.showSoftInput(windowToken, InputMethodManager.RESULT_UNCHANGED_SHOWN);
		}
	}
}
